<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <!-- 靠右的按钮 -->
        <div style="color:pink">说明：目前支持学科和关键字条件筛选</div>
        <el-row type="flex" justify="end">
          <el-button type="success" icon="el-icon-edit" @click="$router.push('/questions/new')">新增试题</el-button>
        </el-row>
        <!-- 选择框 -->
        <el-row>
          <el-col :span="24">
            <el-form :model="formatDate" :inline="true" label-width="40px">
              <el-col :span="6">
                <el-form-item label="学科" prop="subjectID">
                  <el-select v-model="formatDate.subjectID" placeholder="请选择" style="width:160px" @change="getTwoLevel">
                    <el-option v-for="item in subjects" :key="item.id" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="二级目录" prop="twoLevelDirectory">
                  <el-select v-model="formatDate.twoLevelDirectory" placeholder="请选择" style="width:160px">
                    <el-option v-for="(item,index) in twoLevelDirectorys" :key="index" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="标签" prop="label">
                  <el-select v-model="formatDate.label" placeholder="请选择" style="width:160px">
                    <el-option v-for="item in labels" :key="item.id" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="关键字" prop="keywords">
                  <el-input v-model="formatDate.keywords" style="width:160px" placeholder="根据题干搜索" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="试题类型" prop="questionType">
                  <el-select v-model="formatDate.questionType" placeholder="请选择" style="width:160px">
                    <el-option v-for="item in questionType" :key="item.id" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="难度" prop="difficulty">
                  <el-select v-model="formatDate.difficulty" placeholder="请选择" style="width:160px">
                    <el-option v-for="item in difficulty" :key="item.id" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="方向" prop="direction">
                  <el-select v-model="formatDate.direction" placeholder="请选择" style="width:160px"><el-option v-for="item in directions" :key="item.id" :label="item.label" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="录入人" prop="creatorID">
                  <el-select v-model="formatDate.creatorID" placeholder="请选择" style="width:160px">
                    <el-option v-for="item in Inputpeople" :key="item.id" :label="item.username" :value="item.id" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="题目备注" prop="remarks">
                  <el-input v-model="formatDate.remarks" style="width:160px" /></el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="企业简称" prop="abbreviation">
                  <el-input v-model="formatDate.abbreviation" style="width:160px" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="城市" prop="city">
                  <el-select v-model="formatDate.city" size="small" style="width:80px" @focus="creatcity" @change="creatarea">
                    <el-option v-for="(item,index) in citylist" :key="index" :label="item" :value="item" />
                  </el-select>
                  <el-select v-model="formatDate.area" size="small" style="width:80px">
                    <el-option v-for="(item,index) in area" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-row type="flex" justify="center" style="margin-left:80px">
                  <el-button @click="eliminate">清除</el-button>
                  <el-button type="primary" @click="searchs">搜索</el-button>
                </el-row>
              </el-col>
            </el-form>
          </el-col>

        </el-row>
        <!-- 内容区域 -->
        <el-row>
          <el-tabs v-model="activeName" type="card" @tab-click="handleClick(activeName)">
            <el-tab-pane label="全部" name="first">
              <el-alert
                :title="`数据一共${page.total}条`"
                type="info"
                show-icon
                :closable="false"
              />
              <el-table :data="list" style="width: 100%">
                <el-table-column label="试题编号" prop="number">
                  <template slot-scope="{row}">
                    {{ row.number }}
                  </template>
                </el-table-column>
                <el-table-column label="学科" prop="subject">
                  <template slot-scope="{row}">
                    {{ row.subject }}
                  </template>
                </el-table-column>
                <el-table-column label="目录" prop="catalogID">
                  <template slot-scope="{row}">
                    {{ row.catalogID }}
                  </template>
                </el-table-column>
                <el-table-column label="题型" prop="questionType">
                  <template slot-scope="{row}">
                    <div v-show="row.questionType==1">单选</div>
                    <div v-show="row.questionType==2">多选</div>
                    <div v-show="row.questionType==3">简答</div>
                  </template>
                </el-table-column>
                <el-table-column label="题干" prop="question">
                  <template slot-scope="{row}">
                    <div v-html="row.question" />
                  </template>
                </el-table-column>
                <el-table-column label="录入时间" prop="addDate" :formatter="formatter" />
                <el-table-column label="难度" prop="difficulty">
                  <template slot-scope="{row}">
                    <!-- <div v-for="item in EmployeeEnum.difficulty" :key="item.id" :label="item.label" :value="item.value" /> -->
                    <div v-if="row.difficulty==1">简单</div>
                    <div v-if="row.difficulty==2">一般</div>
                    <div v-if="row.difficulty==3">困难</div>
                  </template>
                </el-table-column>
                <el-table-column label="录入人" prop="creatorID">
                  <template slot-scope="{row}">
                    {{ row.creatorID=2?'超级管理员':'录入管理员' }}
                  </template>
                </el-table-column>
                <el-table-column label="审核状态" prop="chkState">
                  <template slot-scope="{row}">
                    <div v-show="row.chkState==0">待审核</div>
                    <div v-show="row.chkState==1">通过</div>
                    <div v-show="row.chkState==2">拒绝</div>
                  </template>
                </el-table-column>
                <el-table-column label="审核意见" prop="chkRemarks">
                  <template slot-scope="{row}">
                    {{ row.chkRemarks }}
                  </template>
                </el-table-column>
                <el-table-column label="审核人" prop="chkUser">
                  <template slot-scope="{row}">
                    {{ row.chkUser }}
                  </template>
                </el-table-column>
                <el-table-column label="发布状态" prop="publishState">
                  <template slot-scope="{row}">
                    <div v-show="row.publishState==0">待发布</div>
                    <div v-show="row.publishState==1">已发布</div>
                    <div v-show="row.publishState==2">已下架</div>
                  </template>
                </el-table-column>

                <el-table-column
                  prop="operation"
                  label="操作"
                  fixed="right"
                  width="190"
                  align="center"
                >
                  <template slot-scope="{row}">
                    <el-button type="text" size="small" @click="preview(row)">预览</el-button>
                    <el-button type="text" size="small" :disabled="row.chkState==1" @click="examine(row)">审核</el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="$router.push({path:'new',query:{id:row.id}})">修改</el-button>
                    <el-button type="text" size="small" :disabled="row.creatorID!=='超级管理员'" @click="choicePublish(row)">
                      <div v-show="row.publishState==0">上架</div>
                      <div v-show="row.publishState==1">下架</div>
                    </el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="remove(row)">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="待审核" name="0">
              <el-alert
                :title="`数据一共${page.total}条`"
                type="info"
                show-icon
                :closable="false"
              />
              <el-table :data="list" style="width: 100%">
                <el-table-column label="试题编号" prop="number">
                  <template slot-scope="{row}">
                    {{ row.number }}
                  </template>
                </el-table-column>
                <el-table-column label="学科" prop="subject">
                  <template slot-scope="{row}">
                    {{ row.subject }}
                  </template>
                </el-table-column>
                <el-table-column label="目录" prop="catalogID">
                  <template slot-scope="{row}">
                    {{ row.catalogID }}
                  </template>
                </el-table-column>
                <el-table-column label="题型" prop="questionType">
                  <template slot-scope="{row}">
                    <div v-show="row.questionType==1">单选</div>
                    <div v-show="row.questionType==2">多选</div>
                    <div v-show="row.questionType==3">简答</div>
                  </template>
                </el-table-column>
                <el-table-column label="题干" prop="question">
                  <template slot-scope="{row}">
                    <div v-html="row.question" />
                  </template>
                </el-table-column>
                <el-table-column label="录入时间" prop="addDate" :formatter="formatter" />
                <el-table-column label="难度" prop="difficulty">
                  <template slot-scope="{row}">
                    <!-- <div v-for="item in EmployeeEnum.difficulty" :key="item.id" :label="item.label" :value="item.value" /> -->
                    <div v-show="row.difficulty==1">简单</div>
                    <div v-show="row.difficulty==2">一般</div>
                    <div v-show="row.difficulty==3">困难</div>
                  </template>
                </el-table-column>
                <el-table-column label="录入人" prop="creatorID">
                  <template slot-scope="{row}">
                    {{ row.creatorID=2?'超级管理员':'录入管理员' }}
                  </template>
                </el-table-column>
                <el-table-column label="审核状态" prop="chkState">
                  <template slot-scope="{row}">
                    <div v-show="row.chkState==0">待审核</div>
                    <div v-show="row.chkState==1">通过</div>
                    <div v-show="row.chkState==2">拒绝</div>
                  </template>
                </el-table-column>
                <el-table-column label="审核意见" prop="chkRemarks">
                  <template slot-scope="{row}">
                    {{ row.chkRemarks }}
                  </template>
                </el-table-column>
                <el-table-column label="审核人" prop="chkUser">
                  <template slot-scope="{row}">
                    {{ row.chkUser }}
                  </template>
                </el-table-column>
                <el-table-column label="发布状态" prop="publishState">
                  <template slot-scope="{row}">
                    <div v-show="row.publishState==0">待发布</div>
                    <div v-show="row.publishState==1">已发布</div>
                    <div v-show="row.publishState==2">已下架</div>
                  </template>
                </el-table-column>

                <el-table-column
                  prop="operation"
                  label="操作"
                  fixed="right"
                  width="190"
                  align="center"
                >
                  <template slot-scope="{row}">
                    <el-button type="text" size="small" @click="preview(row)">预览</el-button>
                    <el-button type="text" size="small" :disabled="row.chkState==1" @click="examine(row)">审核</el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="$router.push({path:'new',query:{id:row.id}})">修改</el-button>
                    <el-button type="text" size="small" :disabled="row.creatorID!=='超级管理员'" @click="choicePublish(row)">
                      <div v-show="row.publishState==0">上架</div>
                      <div v-show="row.publishState==1">下架</div>
                    </el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="remove(row)">删除</el-button>
                  </template>
                </el-table-column>
              </el-table></el-tab-pane>
            <el-tab-pane label="已审核" name="1">
              <el-alert
                :title="`数据一共${page.total}条`"
                type="info"
                show-icon
                :closable="false"
              />
              <el-table :data="list" style="width: 100%">
                <el-table-column label="试题编号" prop="number">
                  <template slot-scope="{row}">
                    {{ row.number }}
                  </template>
                </el-table-column>
                <el-table-column label="学科" prop="subject">
                  <template slot-scope="{row}">
                    {{ row.subject }}
                  </template>
                </el-table-column>
                <el-table-column label="目录" prop="catalogID">
                  <template slot-scope="{row}">
                    {{ row.catalogID }}
                  </template>
                </el-table-column>
                <el-table-column label="题型" prop="questionType">
                  <template slot-scope="{row}">
                    <div v-show="row.questionType==1">单选</div>
                    <div v-show="row.questionType==2">多选</div>
                    <div v-show="row.questionType==3">简答</div>
                  </template>
                </el-table-column>
                <el-table-column label="题干" prop="question">
                  <template slot-scope="{row}">
                    <div v-html="row.question" />
                  </template>
                </el-table-column>
                <el-table-column label="录入时间" prop="addDate" :formatter="formatter" />
                <el-table-column label="难度" prop="difficulty">
                  <template slot-scope="{row}">
                    <!-- <div v-for="item in EmployeeEnum.difficulty" :key="item.id" :label="item.label" :value="item.value" /> -->
                    <div v-show="row.difficulty==1">简单</div>
                    <div v-show="row.difficulty==2">一般</div>
                    <div v-show="row.difficulty==3">困难</div>
                  </template>
                </el-table-column>
                <el-table-column label="录入人" prop="creatorID">
                  <template slot-scope="{row}">
                    {{ row.creatorID=2?'超级管理员':'录入管理员' }}
                  </template>
                </el-table-column>
                <el-table-column label="审核状态" prop="chkState">
                  <template slot-scope="{row}">
                    <div v-show="row.chkState==0">待审核</div>
                    <div v-show="row.chkState==1">通过</div>
                    <div v-show="row.chkState==2">拒绝</div>
                  </template>
                </el-table-column>
                <el-table-column label="审核意见" prop="chkRemarks">
                  <template slot-scope="{row}">
                    {{ row.chkRemarks }}
                  </template>
                </el-table-column>
                <el-table-column label="审核人" prop="chkUser">
                  <template slot-scope="{row}">
                    {{ row.chkUser }}
                  </template>
                </el-table-column>
                <el-table-column label="发布状态" prop="publishState">
                  <template slot-scope="{row}">
                    <div v-show="row.publishState==0">待发布</div>
                    <div v-show="row.publishState==1">已发布</div>
                    <div v-show="row.publishState==2">已下架</div>
                  </template>
                </el-table-column>

                <el-table-column
                  prop="operation"
                  label="操作"
                  fixed="right"
                  width="190"
                  align="center"
                >
                  <template slot-scope="{row}">
                    <el-button type="text" size="small" @click="preview(row)">预览</el-button>
                    <el-button type="text" size="small" :disabled="row.chkState==1" @click="examine(row)">审核</el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="$router.push({path:'new',query:{id:row.id}})">修改</el-button>
                    <el-button type="text" size="small" :disabled="row.creatorID!=='超级管理员'" @click="choicePublish(row)">
                      <div v-show="row.publishState==0">上架</div>
                      <div v-show="row.publishState==1">下架</div>
                    </el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="remove(row)">删除</el-button>
                  </template>
                </el-table-column>
              </el-table></el-tab-pane>
            <el-tab-pane label="已拒绝" name="2">
              <el-alert
                :title="`数据一共${page.total}条`"
                type="info"
                show-icon
                :closable="false"
              />
              <el-table :data="list" style="width: 100%">
                <el-table-column label="试题编号" prop="number">
                  <template slot-scope="{row}">
                    {{ row.number }}
                  </template>
                </el-table-column>
                <el-table-column label="学科" prop="subject">
                  <template slot-scope="{row}">
                    {{ row.subject }}
                  </template>
                </el-table-column>
                <el-table-column label="目录" prop="catalogID">
                  <template slot-scope="{row}">
                    {{ row.catalogID }}
                  </template>
                </el-table-column>
                <el-table-column label="题型" prop="questionType">
                  <template slot-scope="{row}">
                    <div v-show="row.questionType==1">单选</div>
                    <div v-show="row.questionType==2">多选</div>
                    <div v-show="row.questionType==3">简答</div>
                  </template>
                </el-table-column>
                <el-table-column label="题干" prop="question">
                  <template slot-scope="{row}">
                    <div v-html="row.question" />
                  </template>
                </el-table-column>
                <el-table-column label="录入时间" prop="addDate" :formatter="formatter" />
                <el-table-column label="难度" prop="difficulty">
                  <template slot-scope="{row}">
                    <!-- <div v-for="item in EmployeeEnum.difficulty" :key="item.id" :label="item.label" :value="item.value" /> -->
                    <div v-show="row.difficulty==1">简单</div>
                    <div v-show="row.difficulty==2">一般</div>
                    <div v-show="row.difficulty==3">困难</div>
                  </template>
                </el-table-column>
                <el-table-column label="录入人" prop="creatorID">
                  <template slot-scope="{row}">
                    {{ row.creatorID=2?'超级管理员':'录入管理员' }}
                  </template>
                </el-table-column>
                <el-table-column label="审核状态" prop="chkState">
                  <template slot-scope="{row}">
                    <div v-show="row.chkState==0">待审核</div>
                    <div v-show="row.chkState==1">通过</div>
                    <div v-show="row.chkState==2">拒绝</div>
                  </template>
                </el-table-column>
                <el-table-column label="审核意见" prop="chkRemarks">
                  <template slot-scope="{row}">
                    {{ row.chkRemarks }}
                  </template>
                </el-table-column>
                <el-table-column label="审核人" prop="chkUser">
                  <template slot-scope="{row}">
                    {{ row.chkUser }}
                  </template>
                </el-table-column>
                <el-table-column label="发布状态" prop="publishState">
                  <template slot-scope="{row}">
                    <div v-show="row.publishState==0">待发布</div>
                    <div v-show="row.publishState==1">已发布</div>
                    <div v-show="row.publishState==2">已下架</div>
                  </template>
                </el-table-column>

                <el-table-column
                  prop="operation"
                  label="操作"
                  fixed="right"
                  width="190"
                  align="center"
                >
                  <template slot-scope="{row}">
                    <el-button type="text" size="small" @click="preview(row)">预览</el-button>
                    <el-button type="text" size="small" :disabled="row.chkState==1" @click="examine(row)">审核</el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="$router.push({path:'new',query:{id:row.id}})">修改</el-button>
                    <el-button type="text" size="small" :disabled="row.creatorID!=='超级管理员'" @click="choicePublish(row)">
                      {{ row.publishState===0?'上架':'下架' }}
                    </el-button>
                    <el-button type="text" size="small" :disabled="row.publishState==1" @click="remove(row)">删除</el-button>
                  </template>
                </el-table-column>
              </el-table></el-tab-pane>
          </el-tabs>
        </el-row>
        <!-- 分页 -->
        <el-row type="flex" justify="end">
          <el-pagination
            :current-page="page.page"
            :page-sizes="[5,10,20,50]"
            :page-size="page.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page.total"
            @current-change="changePage"
            @size-change="handleSizeChange"
          />
        </el-row>
      </el-card>
    </div>
    <!-- 封装预览组件 -->
    <Previe :show-dialog.sync="showDialog" :selections="Selections" />
    <!-- 审核模块 -->
    <el-dialog :visible.sync="showexamine" title="题目审核" width="400px">
      <el-row style="margin-bottom:40px">
        <el-radio v-model="radio" label="1">通过</el-radio>
        <el-radio v-model="radio" label="0">拒绝</el-radio>
      </el-row>
      <el-input
        v-model="textarea"
        type="textarea"
        :rows="2"
        placeholder="请输入审核意见"
        style="margin-bottom:40px"
      />
      <el-row type="flex" justify="end">
        <el-button @click="checkbtnCanel">取消</el-button>
        <el-button type="primary" @click="checkbtnOK">确认</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
import Previe from '../components/preview.vue'
import { parseTime } from '../../utils/index'
import { choice, remove, detail as details, choiceCheck, choicePublish } from '../../api/hmmm/questions'
import { difficulty, questionType } from '../../api/hmmm/constants'
import { simple } from '../../api/hmmm/subjects'
import { simple as simples } from '../../api/hmmm/directorys'
import { detail } from '../../api/hmmm/tags'
import { list as lister } from '../../api/base/users'
import { provinces, citys } from '../../api/hmmm/citys'
export default {
  name: 'CCCC',
  components: {
    Previe
  },
  data() {
    return {
      radio: '1',
      page: {
        page: 1, // 当前页码
        pagesize: 5,
        total: 0 // 总数
      },
      rows: null,
      formatDate: {
        subjectID: null, // 学科
        difficulty: null, // 难度
        twoLevelDirectory: null, // 二级目录
        questionType: null, // 题型
        label: null, // 标签
        keywords: null, // 关键字
        direction: null, // 方向
        creatorID: null, // 录入人
        city: null, // 城市
        area: null, // 区域
        remarks: null, // 备注
        abbreviation: null // 企业简称
      },
      checkstate: null, // 筛选
      textarea: '', // 文本输入内容
      showgoline: false, // 控制上下线弹层
      showexamine: false, // 控制审核弹层的显示与隐藏
      showDialog: false, // 控制预览弹层的显示与隐藏
      citys, // 区域
      questionType, // 类型
      difficulty, // 难易
      directions: [{
        value: '选项1',
        label: '020'
      }, {
        value: '选项2',
        label: '外包服务'
      }, {
        value: '选项3',
        label: '互联网金融'
      }, {
        value: '选项4',
        label: '企业咨询'
      }, {
        value: '选项5',
        label: '互联网'
      }, {
        value: '选项6',
        label: '电子商务'
      }, {
        value: '选项7',
        label: '其他'
      }], // 方向
      provinces, // 城市
      labelPosition: 'all', // 选择框默认值
      list: [],
      subjects: [], // 学科
      twoLevelDirectorys: [], // 目录
      labels: [], // 标签
      Inputpeople: [], // 录入人员
      citylist: [], // 城市列表
      area: [], // 区域列表
      procity: {}, // 所选区域
      activeName: 'first', // 标签页
      Selections: {} // 预选数据
    }
  },
  computed: {
    linegone() {
      return this.rows.publishState === 0 ? '上架' : '下架'
    }
  },
  created() {
    this.choice() // 渲染页面
    this.simple() // 获取简单列表
    this.lister()
  },
  methods: {
    // 格式化时间
    formatter(row, column, cellValue, index) {
      return parseTime(cellValue)
    },
    // 获取学科简单列表
    async simple() {
      const { data } = await simple()
      this.subjects = data
    },
    // 学科的change事件
    getTwoLevel() {
      this.getcatalog() // 获取二级目录
      this.gettags() // 获取标签
    },
    // 点击学科获取目录
    async getcatalog() {
      const { data } = await simples({ subjectID: this.formatDate.subjectID })
      this.twoLevelDirectorys = data
    },
    // 获取标签
    async gettags() {
      const { data } = await detail({ subjectID: this.formatDate.subjectID })
      this.labels = data
    },
    // 获取录入人
    async lister() {
      const { data } = await lister({ keyword: null })
      this.Inputpeople = data.list
    },
    // 获取城市
    async creatcity() {
      this.citylist = await provinces()
    },
    // 点击城市获取区域
    creatarea() {
      this.procity = this.formatDate.city
      this.area = this.citys(this.procity)
    },
    // 搜索按钮
    searchs() {
      this.choice()
    },
    // 页码的变化
    changePage(newPage) {
      this.page.page = newPage // 点击当前页
      this.choice() // 渲染页面
    },
    // 根据分页来渲染数据
    handleSizeChange(value) {
      this.page.pagesize = value
      this.choice()
    },
    // 渲染页面
    async choice() {
      const { data } = await choice({ ...this.formatDate, chkState: this.checkstate, ...this.page })
      this.list = data.items
      this.page.total = data.counts
    },
    // 预选按钮
    async preview(row) {
      this.showDialog = true
      const { data } = await details(row)
      this.Selections = data
      console.log(this.Selections)
    },
    // 审核按钮
    async examine(row) {
      this.showexamine = true
      this.rows = row
    },
    // 审核确定按钮
    async checkbtnOK() {
      console.log(this.rows)
      if (this.textarea === '') {
        this.$message.warning('请输入文本内容')
      } else {
        console.log(this.radio)
        choiceCheck({ id: this.rows.id, chkRemarks: this.textarea, chkState: parseInt(this.radio) })
        this.showexamine = false
        this.textarea = ''
        this.$message.success('审核成功')
        this.choice()
      }
    },
    // 审核取消按钮
    checkbtnCanel() {
      this.showexamine = false
      this.textarea = ''
    },
    // 上下线按钮
    async choicePublish(row) {
      let publishState = 0
      const states = row.publishState
      if (states === 0) {
        publishState = 1
      } else {
        publishState = 0
      }
      this.rows = row
      try {
        await this.$confirm(`您确定要${this.linegone}这道题目吗？`, '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' })
        await choicePublish({ id: this.rows.id, publishState })
        this.$message.success('操作成功')
        this.choice()
      } catch (error) {
        console.log(error)
      }
    },

    // 删除数据
    async remove(row) {
      try {
        await this.$confirm('此操作将永久删除该题目, 是否继续?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' })
        console.log(row)
        await remove(row)
        this.$message.success('删除成功')
        const totalPage = Math.ceil((this.page.total - 1) / this.page.pagesize) // 总页数
        const currentPage = this.page.page > totalPage ? totalPage : this.page.page
        this.page.page = currentPage < 1 ? 1 : currentPage
        this.choice()
      } catch (error) {
        console.log(error)
      }
    },
    // 清除按钮
    eliminate() {
      this.formatDate = {
        subjectID: null,
        difficulty: null,
        twoLevelDirectory: null,
        questionType: null,
        label: null,
        keywords: null,
        direction: null,
        creatorID: null,
        city: null,
        area: null,
        remarks: null,
        abbreviation: null
      }
      this.choice()
    },
    // 筛选按钮
    handleClick(name) {
      if (name === 'first') {
        this.checkstate = null
        this.choice()
        return
      } else {
        this.checkstate = name
        this.choice()
      }
    }
  }
}
</script>

<style scoped>
.el-row{
  margin-bottom: 20px;
}
</style>
